﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections.Generic;
using DevExpress.Web.ASPxNavBar;

namespace AntroposWeb
{
    public partial class SitePrivado : System.Web.UI.MasterPage
    {
        List<menus> lista = new List<menus>();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {


                lista.Add(new menus() { nombreMenu = "Menu1", NombreSubmenu = "Cuestionario" });
                lista.Add(new menus() { nombreMenu = "Menu2", NombreSubmenu = "Cuestionario2" });
                CargarMenu(this.MenuPrivado, lista);
            }
        }

        private void CargarMenu(ASPxNavBar navBar, List<menus> listMenu)
        {
            Dictionary<string, NavBarGroup> navGroups =
               new Dictionary<string, NavBarGroup>();

            navBar.Groups.Clear();

            foreach (menus item in listMenu)
            {
                if (navGroups.ContainsKey(item.nombreMenu))
                {
                    navGroups[item.nombreMenu].Items.Add(new NavBarItem(item.NombreSubmenu));
                }
                else
                {
                    NavBarGroup navG = navBar.Groups.Add(item.nombreMenu, item.nombreMenu);
                    navG.Items.Add(new NavBarItem(item.NombreSubmenu));
                    navGroups.Add(item.nombreMenu, navG);
                }
            }


        }

        public class menus
        {
            public string nombreMenu { get; set; }
            public string NombreSubmenu { get; set; }
        }
    }
}